<!doctype html>
<html lang="{{ config('app.locale') }}">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover">
  <meta name="_token" content="{{ csrf_token() }}"/>

  <link href="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/css/insect.css?v={{config('app.version')}}" rel="stylesheet" type="text/css">


  <title>Qkids久趣英语</title>

</head>
<body>

<div class="banner-wrapper">
  <img style="-webkit-user-select: none;" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/top_bg.jpg">
  {{--<div class="play-icon-2" id="viewVideo2" style="top: 80vw;left: 45vw;"></div>--}}
  <div class="play-icon" id="viewVideo" style="top: 80vw;left: 45vw;"></div>
  <script>
    var v1 = document.getElementById('viewVideo'), v2 = document.getElementById('viewVideo2'),
      colorOn = 'rgba(36, 193, 121, 1)',
      colorOff = 'rgba(36, 193, 121, 0)',
      radiusOn = '10px ',
      radiusOff = '0px 0px 0px 0px ',
      on =
        radiusOn + radiusOn + radiusOn + radiusOn + colorOff + ',' +
        radiusOn + '-' + radiusOn + radiusOn + radiusOn + colorOff + ',' +
        '-' + radiusOn + radiusOn + radiusOn + radiusOn + colorOff + ',' +
        '-' + radiusOn + '-' + radiusOn + radiusOn + radiusOn + colorOff,
      off =
        radiusOff + colorOn + ',' +
        radiusOff + colorOn + ',' +
        radiusOff + colorOn + ',' +
        radiusOff + colorOn;


    var count = true
    v1.style.transition = 'transform 0.7s linear 0s'
    setInterval(function () {
      v1.style.transform = 'scale(' + (count ? '1.2' : '1') + ')'
      count = !count
    }, 700)

    // v1.style.boxShadow = off
    // v2.style.boxShadow = off
    // animation()
    // setInterval(animation, 10000)

    function animation () {
      console.log('v1=on')
      v1.style.transition = 'box-shadow 9.9s linear 0s'
      v1.style.boxShadow = on
      setTimeout(function () {
        console.log('v1=off')
        v1.style.transition = ''
        v1.style.boxShadow = off
      }, 9900)
      setTimeout(function () {
        console.log('v2=on')
        v2.style.transition = 'box-shadow 9.9s linear 0s'
        v2.style.boxShadow = on
        setTimeout(function () {
          console.log('v2=off')
          v2.style.transition = ''
          v2.style.boxShadow = off
        }, 9900)
      }, 5000)
    }
  </script>
  <div id="switch-account" class="switch-account">登录</div>
</div>

<div class="wrapper">

  <div class="section" style="padding: 8px 0 0 0;background-color: #1EA866;">
    <div class="fixed-btns">
      <div class="stick-buyAlone-btn" data-field="{{$extraCampaignProduct['p_id']}}">￥29.9单独购</div>
      <div id="applyGroupFix" class="stick-group-btn" data-field="{{$campaignProduct['p_id']}}">
        立即开团
      </div>
      <div id="stop" class="stick-group-btn" style="display: none;left: 2.4%;width: 95.2%;">
        活动已停止
      </div>
    </div>
    <div id="groupBuyDetail">
      <div class="group-buy-list" id="groupBuyList">

        <div class="group-member first-member">
          <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/empty.png">
          <span>第1人</span>
        </div>

        <div class="group-member second-member">
          <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/empty.png">
          <span>第2人</span>
        </div>

        <div class="group-member third-member">
          <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/empty.png">
          <span>第3人</span>
        </div>
      </div>
      <img class="group-buy-bg" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/member.png">
      <div class="group-buy-status" id="groupBuyStatus" style="display: none !important;">
      </div>
    </div>
    <div class="notice">
      成团时间：
      <span class="day">02</span>天
      <span class="hour">00</span>:
      <span class="min">00</span>:
      <span class="sec">00</span>
    </div>
  </div>


  <div class="section" style="padding:10px 0 55px 0;background-color: #1EA866;">
    <div class="header" style="margin-top: 0;width: 40.53vw;">
      <img src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/title-1.png">
    </div>
    <div class="camp-step">
      <div class="item">
        <div class="group-buy-step1 icon"></div>
        <span>开团当团长</span>
      </div>
      <div class="item">
        <div class="group-buy-step2 icon"></div>
        <span>参团支付</span>
      </div>
      <div class="item">
        <div class="group-buy-step3 icon"></div>
        <span>邀请好友参团</span>
      </div>
      <div class="item">
        <div class="group-buy-step4 icon"></div>
        <span>团购完成</span>
      </div>
      <div>
        <div class="connect-line"></div>
        <div class="connect-line"></div>
        <div class="connect-line"></div>
      </div>
    </div>
  </div>

  <div class="section" style="padding: 0;margin: 0;font-size: 0;">
    <img style="margin: 0;-webkit-user-select: none;" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/story-1.jpg">
  </div>
  <div class="section" style="padding: 0;margin: 0;font-size: 0;">
    <img style="margin: 0;-webkit-user-select: none;" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/story-2.jpg">
    <div class="lesson-section">
      <div id="section-bar" class="section-bar"></div>
      <div class="section-text">
        <div id="difficulty-1" class="section-text-item" style="color: #FFEDC9;" onclick="sectionItemClick(1)">难度A</div>
        <div id="difficulty-2" class="section-text-item" onclick="sectionItemClick(2)">难度B</div>
        <div id="difficulty-3" class="section-text-item" onclick="sectionItemClick(3)">难度C</div>
      </div>
      <div class="section-line"></div>
    </div>
    <div class="three-difficulty-wrap">
      <div id="three-difficulty" class="three-difficulty">
        <img style="-webkit-user-select: none;" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/story-2-1.png">
        <img style="-webkit-user-select: none;" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/story-2-2.png">
        <img style="-webkit-user-select: none;" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/story-2-3.png">
      </div>
    </div>

    <script>
      function sectionItemClick (index) {
        var sectionTextItem = document.getElementsByClassName('section-text-item')
        setTimeout(function () {
          for (var i = 0; i < sectionTextItem.length; i++) sectionTextItem[i].style.color = '#9A6322'
          document.getElementById('difficulty-' + index).style.color = '#FFEDC9'
        }, 150)
        document.getElementById('section-bar').style.transform = 'translate(' + ((index - 1) * 116) + '%, 0)'
        document.getElementById('three-difficulty').style.transform = 'translate(-' + ((index - 1) * 100) / 3 + '%, 0)'
      }
    </script>
  </div>
  <div class="section" style="padding: 0;margin: 0;font-size: 0;">
    <img style="margin: 0;" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/story-3.jpg">
  </div>
  <div class="section" style="padding: 0;margin: 0;font-size: 0;">
    <img style="margin: 0;pointer-events: auto;" onclick="return false" src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/story-4.jpg">
  </div>

  <div class="video-mask" id="videoMask">
    <div class="close-icon icon" id="closeVideo"></div>
    <div id="videoContainer" class="video">
    </div>
    <style>
      .vcp-player {
        margin: 0 auto;
      }
    </style>
  </div>


  <div class="buy-restrict">
    <div class="info">
      您已经购买过 ¥100／4课时，建议您购买长期课时
    </div>

    <a href="/wx/vip">
      <div class="small-btn confirm-btn">前往购买</div>
    </a>

  </div>


  <div class="group-status" id="groupStatus">
    <div class="explanation">

      <div class="top-banner">
        {{--<img class="santa sad-santa"--}}
        {{--src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/sad_santa.png">--}}
        {{--<img class="santa happy-santa"--}}
        {{--src="{{env('CDN_RESOURCE')}}/mobile/campaign/insect/img/happy_santa.png">--}}

      </div>

      <div class="content">
        <div class="group-detail">
          <div class="title"></div>
          <div class="text"></div>
        </div>
        <div class="reg-btn ok-btn" id="okBtn">确定</div>
      </div>
    </div>
  </div>

  <div class="group-status" id="closeBuy">
    <div class="explanation">

      <div class="top-banner"></div>

      <div class="content">
        <div class="group-detail">
          <div class="title">提示</div>
          <div class="text">本期拼读课名额已抢完，请您留意微信"久趣英语服务号"的招募推送，我们下期见~</div>
        </div>
        <div style="text-align: center;">
          <div class="reg-btn ok-btn" style="width: 80%; display: inline-block;" id="cancelBtn1"
               onclick="document.getElementById('closeBuy').style.display='none'">取消
          </div>
        </div>
      </div>

    </div>
  </div>

  <div class="group-status" id="confirmBuy">
    <div class="explanation">

      <div class="top-banner"></div>

      <div class="content">
        <div class="group-detail">
          <div class="title">提示</div>
          <div class="text">拼读课程目前推出L1级别，适合4-6岁，零基础或有半年以内英语基础的孩子学习。请确认是否报名。</div>
        </div>
        <div style="text-align: center;">
          <div class="reg-btn ok-btn"
               style="width: 35%; display: inline-block;margin-right: 5%;background-color: #85D84B;" id="buy-btn">购买
          </div>
          <div class="reg-btn ok-btn" style="width: 35%; display: inline-block;" id="cancelBtn"
               onclick="document.getElementById('confirmBuy').style.display='none'">取消
          </div>
        </div>
      </div>

    </div>
  </div>

  <div class="buy-restrict">
    <div class="info">
      您已经购买过 ¥100／4课时，建议您购买长期课时
    </div>

    <a href="/wx/vip">
      <div class="small-btn confirm-btn">前往购买</div>
    </a>

  </div>


  <div class="share-mask">
    <div class="share-arrow"></div>
    {{--<div class="share-text">点击分享给好友 ^ _ ^ </div>--}}
  </div>

  <div id="alertBox" class="alert-box"></div>

</div>

<script type="text/javascript" src="https://static-app.97kid.com/wx/js/zepto.min.js"></script>
<!--引入微信js-SDK-->
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript" src=" {{env('CDN_RESOURCE')}}/js/mobile/wx_config.js?v={{config('app.version')}}"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/Zepto_fx_methods.js"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/login.js?v={{config('app.version')}}"></script>
<script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/AV.analytics.js"></script>


<script type="text/javascript">

  (function ($) {

    $(function () {
      if (utils.getUrlParam('alert') === 'qrcode') {
        $('#groupStatus .text').text('微信关注【久趣英语服务号】才能上课')
        $('#groupStatus').show()
      }
      if (!utils.getQueryString('_c')) {
        var QKidsChannel = JSON.parse(window.localStorage.getItem('QKidsChannel'))
        if (!(QKidsChannel && QKidsChannel.expires > new Date().getTime() / 1000)) {
          window.localStorage.setItem('QKidsChannel', JSON.stringify({
            rawData: 'insect_share',
            expires: new Date().getTime() / 1000 + 24 * 3600
          }))
        }
      }

      var CDN_RESOURCE = "{{env('CDN_RESOURCE')}}"
      var currentLevel = 1
      var previousLevel = 1
      var offset = 5
      var isInWechat = false
      var userAgent = navigator.userAgent
      //var userAgent = "Mozilla/5.0(iphone;CPU iphone OS 5_1_1 like Mac OS X) AppleWebKit/534.46(KHTML,like Geocko) Mobile/9B206 MicroMessenger/5.0";
      var wechatInfo = userAgent.match(/MicroMessenger\/([\d\.]+)/i)
      if (wechatInfo) {
        isInWechat = true
      }
      var analytics = AV.analytics({
        appId: 'antYy9lOFi5mkU9QKjtYmRLM-gzGzoHsz',
        appKey: 'jqyWxLyobpsmdwsJddJlDheb',
        channel: isInWechat ? 'weixin' : ''
      })
      window.analytics = analytics

      // 微信活动逻辑
      {
        var configOption = {
          timestamp: '{{$signature['timestamp']}}',
          nonceStr: '{{$signature['nonceStr']}}',
          signature: '{{$signature['signature']}}',
          jsApiList: ['onMenuShareTimeline', 'chooseWXPay', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareQZone']
        }
        var gid = getGId()
        window.gid = gid
        var wxconfig = new WxConfig(configOption, 'insect')
        var shareFlag = ''
        var shareMsg = function () {
          return {
            title: '19.9元4节「久趣昆虫主题课」北美外教带你探索"昆虫的秘密"！',
            desc: '4-12岁，三人成团，在线上课。一起走进奥妙的昆虫世界，get纯正美语！',
            link: window.location.protocol + '//wx2.97kid.com/wx/insect' + Math.ceil(Math.random() * 100) + '?_c=insect&_r=' + shareFlag + (gid ? '&gid=' + gid : ''),
            imgUrl: 'https://static-app.97kid.com/site-student/public/img/share.png',
            success: function (target) {
              analytics.send({
                event: 'insect-share-success',
                attr: {
                  gid: gid,
                  target: target
                }
              })
            }
          }
        }
        wxconfig.activeShare(shareFlag, '', shareMsg())
        var account = new Account()
        var groupBuyStatus = 0
        var campaignEnd = 1539187199
        var creator = 0

        analytics.send({
          event: 'p002_open',
          attr: {
            gid: gid,
            _r: utils.getUrlParam('_r')
          }
        })

        if (new Date().getTime() > 1539187199000) {
          $('.stick-buyAlone-btn').hide()
          $('#applyGroupFix').hide()
          $('#stop').show()
        }

        function getGId () {
          var gid = '{{$gid}}'
          if (!gid) {
            var path = localStorage.getItem('QKidsPathname')

            function getMatched (name, string) {
              if (string) {
                var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
                var len = string.indexOf('?') == 0 ? 1 : 0
                var r = string.substr(len).match(reg)
                if (r != null) return unescape(r[2])
              }
              return null
            }

            var localGid = getMatched('gid', decodeURIComponent(path))
            if (localGid) gid = localGid
          }
          return gid
        }

        account.forceLogin = false
        account.getUserInfo(function (err, userInfo) {
          gid = getGId()
          if (!err && userInfo && userInfo.shareFlag) {
            $('#switch-account').text('切换账号');
            shareFlag = userInfo.shareFlag
            wxconfig.activeShare(shareFlag, '', shareMsg())
          }
          if (gid || !err) {
            getGroupBuyInfo(gid)
          }
          var weChatCode = utils.getQueryString('code');
          var authCallback = account.getAuthCallback();
          if (!err && weChatCode && authCallback) {
            try {
              eval(authCallback);
            } catch (e) {
              console.log(e);
            }
          }
          account.setAuthCallback();
        })

        //提交订单
        $('.stick-group-btn, .stick-buyAlone-btn').click(function () {
          var pId = $(this).attr('data-field')
          analytics.send({
            event: pId === '1037' ? 'p002_group_click' : 'p002_bill_click',
            attr: {
              gid: gid,
              pId: pId
            }
          })
          if (groupBuyStatus === 3 && groupBuyStatus === 7) {
            window.location.href = '/wx'
          } else if (groupBuyStatus === 2 || groupBuyStatus === 1) {
            $('.share-mask').fadeIn()
            analytics.send({
              event: 'insect-share-click',
              attr: {
                gid: gid
              }
            })
          } else {
            submitOrder(pId)
          }
        })
        $('#buy-btn').click(function () {
          if (groupBuyStatus === 3 && groupBuyStatus === 7) {
            window.location.href = '/wx'
          } else if (groupBuyStatus === 2 || groupBuyStatus === 1) {
            $('.share-mask').fadeIn()
            analytics.send({
              event: 'insect-share-click',
              attr: {
                gid: gid
              }
            })
          } else {
            $('#confirmBuy').hide()
            submitOrder($(this).attr('data-field'))
          }
        })

        //关闭提示窗口
        $('#okBtn').click(function () {
          $('#groupStatus').fadeOut()
        })

        //关闭分享提示
        $('.share-mask').click(function () {
          $(this).fadeOut()
        })

        function submitOrder (pId) {
          account.setAuthCallback("submitOrder(" + pId + ')');
          var campUrl = window.location.protocol + '//' + window.location.host + '/wx/insect' + Math.ceil(Math.random() * 100) + '?alert=qrcode'
          var campPara = {
            gid: getGId(),
          }
          account.forceLogin = true
          //提交订单久趣后台
          account.getUserInfo(function (userInfoError, userInforesult) {
            if (userInfoError) {
              $.toastAlert(userInfoError.message)
            } else {
              $('#switch-account').text('切换账号');
              if (isInWechat) {
                //配置微信分享接口
                shareFlag = userInforesult.shareFlag
                wxconfig.activeShare(shareFlag, '', shareMsg())
              }
              var payChannel = isInWechat ? 'weixin' : 'alipay'
              account.ajax({
                type: 'GET',
                path: '/s/customers/' + window.localStorage.getItem(account.openId) + '/status',
                success: function (status) {

                  account.ajax({
                    type: 'POST',
                    path: '/s/bills',
                    data: {
                      productId: pId,
                      payChannel: payChannel,
                      returnUrl: status.subscribe ? window.location.protocol + '//' + window.location.host + '/wx/insect' + Math.ceil(Math.random() * 100) : window.location.protocol + '//' + window.location.host + '/wx/verifypayment/' + pId + '?campUrl=' + encodeURIComponent(campUrl),
                      tradeType: 'JSAPI',
                      openId: window.localStorage.getItem(account.openId),
                      groupBuyingId: groupBuyStatus === 5 ? '' : encodeURIComponent(decodeURIComponent(campPara['gid']))
                    },
                    success: function (data) {
                      //唤起微信支付
                      if (data.status !== 'error') {
                        analytics.send({
                          event: pId === '1037' ? 'p002_group_bill' : 'p002_bill',
                          attr: {
                            gid: gid,
                            pid: pId,
                            payChannel: payChannel
                          }
                        })
                        if (isInWechat) {
                          var jsApiParameters = JSON.parse(data.jsApiParameters)
                          jsApiParameters.success = function () {
                            analytics.send({
                              event: pId === '1037' ? 'p002_group_pay_success' : 'p002_pay_success',
                              attr: {
                                gid: gid,
                                pid: pId,
                                payChannel: payChannel
                              }
                            })
                          };
                          if (status.subscribe) jsApiParameters.redirect = window.location.protocol + '//' + window.location.host + '/wx/insect' + Math.ceil(Math.random() * 100)
                          wxconfig.pay(data.bill_id, pId, jsApiParameters, encodeURIComponent(campUrl))
                        } else {
                          window.location.href = data.url
                        }
                      } else {
                        $.toastAlert('下单失败，请重试')
                      }
                    },
                    error: function (err) {
                      if (err.code === 'product.rejected.by.bought.products') {
                        $.toastAlert('您已经参加活动')
                        getGroupBuyInfo()
                      }
                    }
                  })
                },
                error: function (err) {
                  $.toastAlert(err.message, 2)
                }
              })
            }
          })
        }

        {{--function getGroupByResult() {--}}
        {{--account.ajax({--}}
        {{--type: 'POST',--}}
        {{--path: '/s/groupbuy',--}}
        {{--data: {--}}
        {{--groupBuyingId: '{{$gid}}',--}}
        {{--},--}}
        {{--success: function (data) {--}}
        {{--if (data.status !== 'error') {--}}
        {{--setGroupBuyCountDown(data.endAt);--}}
        {{--getGroupBuyerList(data.buyers);--}}

        {{--} else {--}}
        {{--//$.toastAlert('下单失败，请重试');--}}
        {{--}--}}
        {{--},--}}
        {{--error: function (err) {--}}
        {{--//                        $.toastAlert(err.message, 2);--}}
        {{--}--}}
        {{--});--}}
        {{--}--}}

        function getGroupBuyInfo (gid) {
          //已经登陆
          if (!gid) {
            account.ajax({
              type: 'POST',
              path: '/s/products/1037/buying',

              success: function (result) {
                //已经开团
                creator = result.creatorId
                setGroupBuyStatus(result, true)
                getGroupBuyerList(result.buyers.toString())
                resetShareDetail(result.id)

              },
              error: function (err) {
                setGroupBuyStatus(err, false)
              }
            })
          } else {
            account.ajax({
              auth: false,
              type: 'POST',
              path: '/s/products/1037/buying',
              data: {groupBuyingId: encodeURIComponent(gid)},//'fsxz2CTal9g%3D'},
              success: function (result) {
                //已经开团
                creator = result.creatorId
                setGroupBuyStatus(result, true)
                getGroupBuyerList(result.buyers.toString())
                resetShareDetail(result.id)
              },
              error: function (err) {
                setGroupBuyStatus(err, false)
              }
            })
          }
        }

        function getGroupBuyerList (buyers) {
          account.ajax({
            auth: false,
            type: 'GET',
            path: '/s/students/socials',
            data: {ids: buyers},
            success: function (result) {
              showGroupBuyerList(result)
            },
            error: function (err) {
              $.toastAlert(err.message, 2)
            }
          })
        }

        function showGroupBuyerList (wechatInfoList) {

          var referralListHtml = ''
          var sortedList = []

          if (creator !== 0) {
            var captain
            var currentBuyer
            var currentBuyerId = 0
            if (JSON.parse(window.localStorage.getItem(account.userInfoKey)) !== null) {
              currentBuyerId = JSON.parse(window.localStorage.getItem(account.userInfoKey)).id
            }

            for (var k = 0; k < wechatInfoList.length; k++) {
              if ((wechatInfoList[k].id) === creator) {
                captain = wechatInfoList[k]
              } else if (wechatInfoList[k].id === currentBuyerId) {
                currentBuyer = wechatInfoList[k]
              } else {
                sortedList.push(wechatInfoList[k])
              }
            }

            if (currentBuyerId !== creator && currentBuyer) {
              sortedList.unshift(currentBuyer)
            }

            if (captain) {
              sortedList.unshift(captain)
            }
          }

          for (var i = 0; i < Math.min(3, sortedList.length); i++) {

            referralListHtml += '<div class="group-member">' +
              '<img src="' + getAvatar(sortedList[i].avatar) + '" onerror="this.src=\'' + CDN_RESOURCE + '\'/mobile/campaign/insect/img/empty.png\'">' +
              '<span>' + sortedList[i].nickname + '</span>' +
              '</div>'

          }

          for (var j = 0; j < (3 - sortedList.length); j++) {
            referralListHtml += '<div class="group-member">' +
              '<img src="' + '{{env('CDN_RESOURCE')}}' + '/mobile/campaign/insect/img/empty.png" />' +
              '<span>第' + (sortedList.length + j + 1) + '人</span>' +
              '</div>'
          }

          $('#groupBuyList').empty().append(referralListHtml)

        }

        function getAvatar (avatar) {
          if (!avatar) {
            return '{{env('CDN_RESOURCE')}}' + '/img/mobile/campaign/doubleEleven/pic_avatar_boy.png'
          }
          return avatar
        }

        var starCount = null

        function setGroupBuyCountDown (status, endAt) {
          if (starCount) clearInterval(starCount)
          if (status == 0) {
            starCount = setInterval(function () {

              var timestamp = Date.parse(new Date())
              if (timestamp >= endAt) {
                // 团购已经结束
                $('.notice').text('该团购已经到期!')
                clearInterval(starCount)

              } else if (timestamp < endAt) {
                var timeDiff = endAt - timestamp
                var day = Math.floor(timeDiff / 1000 / 60 / 60 / 24)
                var hour = Math.floor(timeDiff / 1000 / 60 / 60 % 24)
                var min = Math.floor(timeDiff / 1000 / 60 % 60)
                var sec = Math.floor(timeDiff / 1000 % 60)

                if (day < 10) {
                  day = '0' + day
                }
                if (hour < 10) {
                  hour = '0' + hour
                }
                if (min < 10) {
                  min = '0' + min
                }
                if (sec < 10) {
                  sec = '0' + sec
                }
                var countDownTime = hour + ':' + min + ':' + sec
                // $('.notice').text('成团时间: ' + day + '天' + countDownTime)
                $('.notice .day').text(day)
                $('.notice .hour').text(hour)
                $('.notice .min').text(min)
                $('.notice .sec').text(sec)
              }
            }, 1000)

          } else if (status == 1) {
            $('.notice').text('已成团')
          } else {
            $('.notice').text('已过期')
          }

        }

        //已登陆

        //setGroupBuyStatus({}, true);
        function setGroupBuyStatus (gpDetail, status) {

          if (!gpDetail || !gpDetail.id) return

          //  status: 1->已报名 2->未报名

//                alert(groupBuyTimeStatus(gpDetail.endAt) + '-'  + campaignTimeStatus());

          var currentBuyerId = 0
          if (JSON.parse(window.localStorage.getItem(account.userInfoKey)) !== null) {
            currentBuyerId = JSON.parse(window.localStorage.getItem(account.userInfoKey)).id
          }

          var inGroup = gpDetail.buyers && gpDetail.buyers.indexOf(currentBuyerId) >= 0

          var cStatus = campaignTimeStatus()

          var endAt1 = new Date().getTime() / 1000 + 1000
          var endAt2 = new Date().getTime() / 1000 - 1000

          //status = true;
          //cStatus = true;
          //inGroup = true;

          // 组团中
          //gpDetail = { id: 1, status: 2, buyerCount: 2, endAt: endAt1, buyers: [9]};
          // 团成功
          //gpDetail = { id: 1, status: 1, buyerCount: 4, endAt: endAt2, buyers: [7,8,9,27]};
          // 团过期
          //gpDetail = { id: 1, status: 2, buyerCount: 4, endAt: endAt2, buyers: [9]};

          setGroupBuyCountDown(gpDetail.status, gpDetail.endAt * 1000)
          if (status) {
            if (gpDetail.status === 0) {
              if (inGroup) displayGroupBuyStatus(2, gpDetail.buyerCount)
              else displayGroupBuyStatus(8, gpDetail.buyerCount)
            } else if (gpDetail.status === 1) {
              if (inGroup) displayGroupBuyStatus(1)
              else {
                if (cStatus) displayGroupBuyStatus(5)
                else displayGroupBuyStatus(7)
              }
            } else {
              if (cStatus) {
                if (inGroup) displayGroupBuyStatus(4)
                else displayGroupBuyStatus(6)
              } else {
                if (inGroup) displayGroupBuyStatus(3)
                else displayGroupBuyStatus(7)
              }
            }
          }
        }

        function groupBuyTimeStatus (groupBuyEnd) {
          return (new Date).getTime() / 1000 <= groupBuyEnd
        }

        function campaignTimeStatus () {
          return (new Date).getTime() / 1000 <= campaignEnd
        }

        function displayGroupBuyStatus (status, buyerCounter) {
          $('.camp-step .icon').removeClass('active')
          if (status === 1) {
            $('.group-buy-step4').addClass('active')
            //happy monkey
            // 团购成功( 已报名 已成团 活动时间未到期 )
            //亲爱的家长，您已成功购入昆虫主题课券（￥19.9/4节课），北美外教给您准备了有趣的课程，快去预约上课吧！

            if (new Date().getTime() > 1539187199000) {
              $('.stick-buyAlone-btn').hide()
              $('#applyGroupFix').hide()
              $('#stop').show()
            } else {
              $('.apply-btn, .stick-group-btn').css('width', '95.2%').css('left', '2.4%').text('团购成功，分享给好友')
              $('.stick-buyAlone-btn').hide()
            }

            $('.group-buy-status').text('当前团购成功')
            // $('.happy-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('团购成功')
            $('#groupStatus .text').text('亲爱的家长，您已成功购入昆虫主题课券（￥19.9/4节课），北美外教给您准备了有趣的课程，快去预约上课吧！<br/>【课劵自购买起30天有效】')
            $('#groupStatus').show()
            groupBuyStatus = 1

          } else if (status === 2) {
            //尚未成团 (已报名 团没有满 团购时间未到期 活动时间还没到期  )
            $('.apply-btn, .stick-group-btn').css('width', '95.2%').css('left', '2.4%').text('邀请好友参团')
            $('.stick-buyAlone-btn').hide()

            $('.group-buy-status').text(' 还差' + (3 - buyerCounter) + '人即可成团，邀请更多好友共享')
            $('#top-btn').text('立即邀请')
            groupBuyStatus = 2
            $('.group-buy-step3').addClass('active')

          } else if (status === 3) {
            //normal monkey
            //活动已结束( 已报名 团没有满 团购时间到期 活动时间已到期)
            //亲爱的家长，您所在的团未在规定时间内组团成功，系统将在3-5个工作日为您自动退款，请注意查收。点击查看其他优惠活动吧。
            if (new Date().getTime() > 1539187199000) {
              $('.stick-buyAlone-btn').hide()
              $('#applyGroupFix').hide()
              $('#stop').show()
            } else {
              $('.apply-btn, .stick-group-btn').text('查看其他优惠').hide()
              $('.stick-buyAlone-btn').css('width', '100%')
            }
            $('.group-buy-status').text('昆虫主题课团购活动已结束')
            // $('.sad-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('活动已结束')
            $('#groupStatus .text').text('亲爱的家长，您所在的团未在规定时间内组团成功，系统将在3-5个工作日为您自动退款，请注意查收。点击查看其他优惠活动吧。')
            $('#groupStatus').show()
            groupBuyStatus = 3

          } else if (status === 4) {
            $('.group-buy-step1').addClass('active')
            //sad monkey
            //很遗憾( 已报名 团没有满 团购时间到期 活动时间未到期)
            //亲爱的家长，您所在的团未在规定时间内组团成功，系统将在3-5个工作日为您自动退款，请注意查收。活动还未结束，重新开团抢昆虫主题课团购优惠吧。
            if (new Date().getTime() > 1539187199000) {
              $('.stick-buyAlone-btn').hide()
              $('#applyGroupFix').hide()
              $('#stop').show()
            } else {
              $('.apply-btn, .stick-group-btn').text('重新开团')
              $('.group-buy-status').text('未能组团成功，请重新开团')
            }
            // $('.sad-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('很遗憾')
            $('#groupStatus .text').text('亲爱的家长，您所在的团未在规定时间内组团成功，系统将在3-5个工作日为您自动退款，请注意查收。活动还未结束，重新开团抢昆虫主题课团购优惠吧。')
            $('#top-btn').text('重新开团')
            $('#groupStatus').show()
            groupBuyStatus = 4

          } else if (status === 5) {
            $('.group-buy-step4').addClass('active')
            //normal monkey
            // 该团已满，重新开团( 未报名 团已满 活动时间未到期 )
            //亲爱的家长，该团已满员，请您重新开团抢昆虫主题课团购优惠吧。
            if (new Date().getTime() > 1539187199000) {
              $('.stick-buyAlone-btn').hide()
              $('#applyGroupFix').hide()
              $('#stop').show()
            } else {
              $('.apply-btn, .stick-group-btn').text('重新开团')
              $('.group-buy-status').text('该团已满员，请重新开团')
            }
            // $('.sad-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('该团已满，重新开团')
            $('#groupStatus .text').text('亲爱的家长，该团已满员，请您重新开团抢昆虫主题课团购优惠吧。')
            $('#groupStatus').show()
            $('#top-btn').text('重新开团')
            groupBuyStatus = 5

          } else if (status === 6) {
            //sad monkey
            //请重新开团(  未报名 团没有满 团购时间已经到期 活动时间未到期)
            //亲爱的家长，该团已结束，请您重新开团抢昆虫主题课团购优惠吧。
            if (new Date().getTime() > 1539187199000) {
              $('.stick-buyAlone-btn').hide()
              $('#applyGroupFix').hide()
              $('#stop').show()
            } else {
              $('.apply-btn, .stick-group-btn').text('重新开团')
              $('.group-buy-status').text('该团团购时间结束，请重新开团')
            }
            // $('.sad-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('请重新开团')
            $('#groupStatus .text').text('亲爱的家长，该团团购时间结束，请您重新开团抢昆虫主题课团购优惠吧。')
            $('#groupStatus').show()
            groupBuyStatus = 6
            $('.group-buy-step1').addClass('active')

          } else if (status === 7) {
            //normal monkey
            //活动已结束( 未报名 活动时间到期 )
            //亲爱的家长，活动已结束，点击查看其他优惠活动吧。
            if (new Date().getTime() > 1539187199000) {
              $('.stick-buyAlone-btn').hide()
              $('#applyGroupFix').hide()
              $('#stop').show()
            } else {
              $('.apply-btn, .stick-group-btn').text('查看其他优惠').hide()
              $('.stick-buyAlone-btn').css('width', '95.2%')
            }

            $('.group-buy-status').text('活动已经结束')
            $('.normal-santa').show().siblings('.santa').hide()
            $('#groupStatus .title').text('活动已结束')
            $('#groupStatus .text').text('亲爱的家长，活动已结束，点击查看其他优惠活动吧。')
            $('#groupStatus').show()
            groupBuyStatus = 7
          } else if (status === 8) {
            //参加活动( 未报名 团购活动没有满 活动时间未到期 )
            $('.apply-btn, .stick-group-btn').text('立即参团').css('width', '95.2%').css('left', '2.4%')
            $('.stick-group-btn').show()
            $('#stop').remove()
            $('.group-buy-status').text(' 还差' + (3 - buyerCounter) + '人即可成团，邀请更多好友共享')
            groupBuyStatus = 8
            $('.group-buy-step2').addClass('active')
          } else if (status === 9) {
            //参加活动( 未报名 团购活动没有满 团购时间到期 活动时间未到期 )
            if (new Date().getTime() > 1539187199000) {
              $('.stick-buyAlone-btn').hide()
              $('#applyGroupFix').hide()
              $('#stop').show()
            } else {
              $('.apply-btn, .stick-group-btn').text('重新开团')
              $('.group-buy-status').text('该团已结束，请重新开团')
            }
            groupBuyStatus = 9
          }
        }

        function resetShareDetail (_gid) {
          var campPara = []
          campPara['gid'] = _gid
          gid = _gid
          account.getUserInfo(function (err, result) {
            if (!err && isInWechat) {
              //配置微信分享接口
              shareFlag = result.shareFlag
              wxconfig.activeShare(shareFlag, '', shareMsg())
            }
          })

        }

        //切换账号
        $('.switch-account').off('click').on('click',function() {
          $('.account-mask').fadeOut();
          account.forceLogin = true;
          account.checkLoginStatus(function() {
            account._showLogin(function () {}, true);
          });
        });
      }
    })

  })(window.Zepto)


</script>

<script src="//imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.2.1.js" charset="utf-8"></script>
<script>
  $(function () {
    var timeStampStart, timeStampEnd, timeout
    //初始化视频
    var player = new TcPlayer(
      //页面放置播放位置的元素 ID
      'videoContainer',
      {
        'm3u8': 'http://1251352844.vod2.myqcloud.com/45f5686avodtransgzp1251352844/5ca0c2d87447398156358308495/v.f20.mp4',
        'autoplay': false,
        'coverpic': '',
        'width': '640',
        'height': '480',
        'live': false,
        'systemFullscreen': true,
      })

    //观看视频
    $('#viewVideo').click(function () {
      $('#videoMask').fadeIn(300)
      player.play()
      timeStampStart = new Date()
      analytics.send({
        event: 'p002_video_open',
        attr: {
          gid: gid,
          _r: utils.getUrlParam('_r')
        }
      })
      timeout = setTimeout(function () {
        analytics.send({
          event: 'p002_video_more_than_minute',
          attr:  {
            gid: gid,
            _r: utils.getUrlParam('_r')
          }
        })
      }, 60000)
    })

    //关闭视频
    $('#closeVideo').click(function () {
      player.pause()
      clearTimeout(timeout)
      timeStampEnd = new Date()
      $('#videoMask').fadeOut(300)
      if ((timeStampEnd - timeStampStart) / 1000 >= 45) {
        analytics.send({
          event: 'p002_video_more_than_minute',
          attr: {
            gid: gid,
            _r: utils.getUrlParam('_r')
          }
        })
      }
      if ((timeStampEnd - timeStampStart) / 1000 >= 65) {
        analytics.send({
          event: 'p002_video_end',
          attr: {
            gid: gid,
            _r: utils.getUrlParam('_r')
          }
        })
      }
    })
  })
</script>


</body>
</html>